Skip to content

Upgrade Telegram/Discord channels: Routine delivery, inline approvals, typing, and offline voice notes - #383

Merged
d41sys merged 1 commit into
mainfrom
issue-376-channel-upgrades
Dec 4, 2026
Merged

d41sys merged 1 commit into
mainfrom
issue-376-channel-upgrades

Conversation

@d41sys

@d41sys d41sys commented Dec 4, 2026

Copy link
Copy Markdown
Owner

Summary

Closes #376.

Upgrades Bate's direct-from-Mac Telegram and Discord channels so a paired chat works as a full away-from-Mac remote without any third-party relay:

  • Shared hidden/reordering character marker (proto/src/reveal.rs): moved reveal / has_hidden into proto (re-exported by native/src/reveal.rs) and added mark_plain ([U+XXXX]) for plain-text channel cards.
  • Routine → Channel delivery (proto/src/routines.rs, appd/src/core.rs, window/ui/src/Routines.tsx, native/src/routines.rs):
    • Optional deliverChannel ("telegram" | "discord") and deliverChat (validated against the bot's currently paired chats) on Routine.
    • Posts a finished routine's final reply (capped to 3,500 chars, hidden chars marked, never including secrets) to the paired chat without duplicating /run replies.
    • Exposes a Send final reply to paired-chat selector in both window/ui and native Routine dialogs, and displays delivery status on routine rows.
  • Inline approval buttons (Allow once / Deny) (appd/src/channels.rs, appd/src/core.rs):
    • Sends interactive Allow once (approve:<qid>) and Deny (deny:<qid>) cards on Telegram (inline_keyboard + callback_query + answerCallbackQuery) and Discord (components + INTERACTION_CREATE callback) when a channel-initiated turn or channel-delivered routine pauses on a question.
    • Strictly enforces no Always button, marks hidden/reordering characters via proto::reveal::mark_plain, and never sends Secret prompts as approval cards (sends a plain redacted notice "The bot needs a secret in Bate on your Mac." with no buttons and refuses any forged callback targeting a Secret question).
  • Typing indicator & bounded inbound attachments / offline voice notes (appd/src/channels.rs, appd/src/core.rs):
    • Periodic typing actions (sendChatAction / /channels/{chat}/typing) run on a background thread while a channel turn executes and stop immediately on turn end, pause on a question, or engine exit.
    • Paired chats can send photos, documents, and voice/audio notes (max 4 attachments, 10 MiB hard limit checked on both reported size and streamed bytes, max_redirects(0), sanitized names written 0o600 inside bots/<bot>/inbox/). Unpaired chats never trigger downloads.
    • Voice notes run local-only on-device transcription (BATE_TRANSCRIBE_CMD or macOS on-device SFSpeechRecognizer with requiresOnDeviceRecognition = true, never cloud speech APIs) off Core::run, falling back cleanly to the saved audio path if unavailable.

Evidence

  • cd window/ui && npm ci && npm run build && npm test: 142/142 passed.
  • cargo fmt --all --check: clean.
  • cargo clippy --workspace --all-targets --locked -- -D warnings: clean.
  • cargo test --workspace --locked: all crates passed, including:
    • appd --test service: channel_upgrades_routine_delivery_inline_approvals_typing_and_attachments covering Routine delivery, unpaired-chat refusal, LAN Device refusal, inline Allow once / Deny callbacks with hidden-character marking, typing indicator, Secret prompt redaction & forged-callback refusal, bounded attachment saving, local offline voice transcription, and > 10 MiB rejection.
    • native --test botpages: routine_delivery_selects_a_paired_channel_chat_and_sends_it plus visually verified light/dark Routine dialog snapshots.

Merge Danger

Low. New Routine fields (deliverChannel, deliverChat) are optional with #[serde(default)], preserving full backward compatibility with existing stored routines and bot export files. All channel I/O and transcription run off Core::run.

Device decision

  • No new window commands added; get_channels remains REFUSED_OVER_LAN.
  • set_routine over LAN refuses (forbidden) any frame carrying deliverChannel or deliverChat (even null), and keepPrecheck: true preserves stored delivery targets when a paired Device edits other routine fields — matching the existing rule for precheck and watch. Documented in PROTOCOL.md.

@d41sys
d41sys merged commit 72b0f2a into main Dec 4, 2026
5 checks passed
@d41sys
d41sys deleted the issue-376-channel-upgrades branch December 4, 2026 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Channel upgrades: Routine delivery, inline Allow once / Deny approvals, typing indicator, and offline voice notes

1 participant